package com.qiyi.player.wonder.plugins.scenetile
{
   import com.qiyi.player.wonder.plugins.AbstractPlugins;
   import com.qiyi.player.wonder.plugins.scenetile.model.SceneTileProxy;
   import flash.display.DisplayObjectContainer;
   import com.qiyi.player.wonder.plugins.scenetile.view.SceneTileToolViewMediator;
   import com.qiyi.player.wonder.plugins.scenetile.view.SceneTileDetailsViewMediator;
   import com.qiyi.player.wonder.plugins.scenetile.view.SceneTileGreenTailViewMediator;
   import com.qiyi.player.wonder.plugins.scenetile.view.SceneTileFocusViewMediator;
   import com.qiyi.player.wonder.plugins.scenetile.controller.SceneTileDetailsOpenCloseCommand;
   import com.qiyi.player.wonder.plugins.scenetile.controller.SceneTileGreenTailOpenCloseCommand;
   import com.qiyi.player.wonder.plugins.scenetile.controller.SceneTileFocusOpenCloseCommand;
   import com.qiyi.player.wonder.plugins.scenetile.view.SceneTileToolView;
   import com.qiyi.player.wonder.common.config.FlashVarConfig;
   import com.iqiyi.components.panelSystem.PanelManager;
   import com.qiyi.player.wonder.plugins.scenetile.view.SceneTileDetailsView;
   import com.qiyi.player.wonder.plugins.scenetile.view.SceneTileGreenTailView;
   import com.qiyi.player.wonder.plugins.scenetile.view.SceneTileFocusView;
   import com.qiyi.player.wonder.common.vo.UserInfoVO;
   import com.qiyi.player.wonder.body.model.UserProxy;
   
   public class SceneTilePlugins extends AbstractPlugins
   {
      
      public function SceneTilePlugins(param1:SingletonClass) {
         super();
      }
      
      private static var _instance:SceneTilePlugins;
      
      public static function getInstance() : SceneTilePlugins {
         if(_instance == null)
         {
            _instance = new SceneTilePlugins(new SingletonClass());
         }
         return _instance;
      }
      
      override public function initModel(param1:Vector.<String> = null) : void {
         var _loc2_:* = 0;
         var _loc3_:* = 0;
         super.initModel(param1);
         if(param1)
         {
            _loc2_ = param1.length;
            _loc3_ = 0;
            while(_loc3_ < _loc2_)
            {
               switch(param1[_loc3_])
               {
                  case SceneTileProxy.NAME:
                     if(!facade.hasProxy(SceneTileProxy.NAME))
                     {
                        facade.registerProxy(new SceneTileProxy());
                     }
                     break;
               }
               _loc3_++;
            }
         }
         else if(!facade.hasProxy(SceneTileProxy.NAME))
         {
            facade.registerProxy(new SceneTileProxy());
         }
         
      }
      
      override public function initView(param1:DisplayObjectContainer, param2:Vector.<String> = null) : void {
         var _loc3_:* = 0;
         var _loc4_:* = 0;
         super.initView(param1,param2);
         if(param2)
         {
            _loc3_ = param2.length;
            _loc4_ = 0;
            while(_loc4_ < _loc3_)
            {
               switch(param2[_loc4_])
               {
                  case SceneTileToolViewMediator.NAME:
                     this.createSceneTileToolViewMediator(param1);
                     break;
                  case SceneTileDetailsViewMediator.NAME:
                     this.createSceneTileDetailsViewMediator(param1);
                     break;
                  case SceneTileGreenTailViewMediator.NAME:
                     this.createSceneTileGreenTailViewMediator(param1);
                     break;
                  case SceneTileFocusViewMediator.NAME:
                     this.createSceneTileFocusViewMediator(param1);
                     break;
               }
               _loc4_++;
            }
         }
         else
         {
            this.createSceneTileToolViewMediator(param1);
            this.createSceneTileDetailsViewMediator(param1);
            this.createSceneTileGreenTailViewMediator(param1);
            this.createSceneTileFocusViewMediator(param1);
         }
      }
      
      override public function initController() : void {
         super.initController();
         facade.registerCommand(SceneTileDef.NOTIFIC_OPEN_CLOSE_DETAILS,SceneTileDetailsOpenCloseCommand);
         facade.registerCommand(SceneTileDef.NOTIFIC_OPEN_CLOSE_GREENTAIL,SceneTileGreenTailOpenCloseCommand);
         facade.registerCommand(SceneTileDef.NOTIFIC_OPEN_CLOSE_FOCUS,SceneTileFocusOpenCloseCommand);
      }
      
      private function createSceneTileToolViewMediator(param1:DisplayObjectContainer) : void {
         var _loc2_:SceneTileProxy = null;
         var _loc3_:SceneTileToolView = null;
         if(!facade.hasMediator(SceneTileToolViewMediator.NAME))
         {
            _loc2_ = facade.retrieveProxy(SceneTileProxy.NAME) as SceneTileProxy;
            if(!FlashVarConfig.autoPlay)
            {
               _loc2_.addStatus(SceneTileDef.STATUS_PLAY_BTN_SHOW,false);
            }
            _loc3_ = new SceneTileToolView(param1,_loc2_.status.clone(),this.createUserInfoVO());
            PanelManager.getInstance().register(_loc3_);
            facade.registerMediator(new SceneTileToolViewMediator(_loc3_));
            _loc2_.addStatus(SceneTileDef.STATUS_TOOL_OPEN);
         }
      }
      
      private function createSceneTileDetailsViewMediator(param1:DisplayObjectContainer) : void {
         var _loc2_:SceneTileProxy = null;
         var _loc3_:SceneTileDetailsView = null;
         if(!facade.hasMediator(SceneTileDetailsViewMediator.NAME))
         {
            _loc2_ = facade.retrieveProxy(SceneTileProxy.NAME) as SceneTileProxy;
            _loc3_ = new SceneTileDetailsView(param1,_loc2_.status.clone(),this.createUserInfoVO());
            PanelManager.getInstance().register(_loc3_);
            facade.registerMediator(new SceneTileDetailsViewMediator(_loc3_));
         }
      }
      
      private function createSceneTileGreenTailViewMediator(param1:DisplayObjectContainer) : void {
         var _loc2_:SceneTileProxy = null;
         var _loc3_:SceneTileGreenTailView = null;
         if(!facade.hasMediator(SceneTileGreenTailViewMediator.NAME))
         {
            _loc2_ = facade.retrieveProxy(SceneTileProxy.NAME) as SceneTileProxy;
            _loc3_ = new SceneTileGreenTailView(param1,_loc2_.status.clone(),this.createUserInfoVO());
            PanelManager.getInstance().register(_loc3_);
            facade.registerMediator(new SceneTileGreenTailViewMediator(_loc3_));
         }
      }
      
      private function createSceneTileFocusViewMediator(param1:DisplayObjectContainer) : void {
         var _loc2_:SceneTileProxy = null;
         var _loc3_:SceneTileFocusView = null;
         if(!facade.hasMediator(SceneTileFocusViewMediator.NAME))
         {
            _loc2_ = facade.retrieveProxy(SceneTileProxy.NAME) as SceneTileProxy;
            _loc3_ = new SceneTileFocusView(param1,_loc2_.status.clone(),this.createUserInfoVO());
            PanelManager.getInstance().register(_loc3_);
            facade.registerMediator(new SceneTileFocusViewMediator(_loc3_));
         }
      }
      
      private function createUserInfoVO() : UserInfoVO {
         var _loc1_:UserProxy = facade.retrieveProxy(UserProxy.NAME) as UserProxy;
         var _loc2_:UserInfoVO = new UserInfoVO();
         _loc2_.isLogin = _loc1_.isLogin;
         _loc2_.passportID = _loc1_.passportID;
         _loc2_.userID = _loc1_.userID;
         _loc2_.userName = _loc1_.userName;
         _loc2_.userLevel = _loc1_.userLevel;
         _loc2_.userType = _loc1_.userType;
         return _loc2_;
      }
   }
}
class SingletonClass extends Object
{
   
   function SingletonClass() {
      super();
   }
}
